/***************************************************************************
 *   Copyright (C) 2009 by Bernhard Neuhofer   *
 *   mail@bneu.at   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef GVTSTATS_H
#define GVTSTATS_H

#include <limits>
/**
* @brief Stores the GVT relevant stats for a SM
*/
class GvtStats
{
private:
/** Color of the submodel, true==white*/
bool 	_color;
/** minimal LVT of all LPs in this submodel*/
double 	_lvtSm;
/** Message difference counter for white message */
int	_mdw;
/** Message difference counter for red message*/
int	_mdr;
/** Minimal timestamp of message with the current color*/
double	_tmin;
/** Last valid GVT approximation */
double	_gvt;



public:
/**
* Constructor which initializes all private variables
*/
GvtStats()
	:_color(true),_lvtSm(-1.0),_mdw(0),_mdr(0),
	_tmin(std::numeric_limits<double>::max()),_gvt(-1.0) 
	{}

/**
 * Returns the color.
 * @return bool
 */
bool getColor();

/**
 * Returns the message difference counter for the given color
 * @param color true=white, false=red (color of the counter)
 * @return int
 */
int getMd(bool color);

/**
 * Returns the minimum Lvt in this SM
 * @return 
 */
double getLvtSm();

/**
 * Returns the ts
 * @return double
 */
double getTmin();

/**
 * Returns the GVT
 * @return double
 */
double getGvt();

/**
 * Changes the color
 */
void changeColor();

/**
 * Sets the color.
 * @param color 
 */
void setColor(bool color);

/**
 * Increases either the white or the red message difference counter
 * @param color The color of the counter
 */
void incMd(bool color);

/**
 * Decreases either the white or the red message difference counter
 * @param color The color of the counter
 */
void decMd(bool color);

/**
 * Sets either the white or the red message difference counter
 * @param color The color of the counter
 * @param md The new value
 */
void setMd(bool color, int md);

/**
 * Reset either the white or the red message difference counter to 0
 * @param color The color of the counter
 */
void resetMd(bool color);

/**
 * Sets the minimum LVT in this SM
 * @param lvtSm The minimum LVT in this SM
 */
void setLvtSm(double lvtSm);

/**
 * Resets the minimal ts.
 */
void resetTmin();

/**
 * Sets the minimal ts
 * @param tmin Minmal timestamp to set
 */
void setTmin(double tmin);

/**
 * Sets the GVT
 * @param gvt Last valid GVT aproximation
 */
void setGvt(double gvt);
};

#endif